package io.github.wppli.domain.user.event;

import io.github.wppli.types.event.BaseEvent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author li--jiaqiang 2025−03−03
 */
@Component
public class AdjustUserFollowedEvent extends BaseEvent<AdjustUserFollowedEvent.AdjustUserFollowedMessage> {

    @Value("${spring.rabbitmq.topic.adjust_user_followed}")
    private String topic;

    @Override
    public EventMessage<AdjustUserFollowedMessage> buildEventMessage(AdjustUserFollowedMessage data) {
        return EventMessage.<AdjustUserFollowedMessage>builder()
                .id(String.valueOf(snowflakeIdGenerator.nextId()))
                .timestamp(new Date())
                .data(data)
                .build();
    }

    @Override
    public String topic() {
        return topic;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class AdjustUserFollowedMessage {
        /**
         * 用户ID
         */
        private Long userId;
        /**
         * 目标用户
         */
        private Long targetUserId;
        /**
         * 关注状态, true: 关注， false: 取关
         */
        private Boolean followed;
    }

}